<template>
    <div>
        <a-modal
         v-model:visible="visible" 
         title="添加自动抽选" 
         @ok="handleOk"
         @cancel="visible = false"
         :width="900"
        >
            <div class="automaticSelectFrom-modal-box-v">
                <table border bordercolor="#d9d9d9" style="width: 100%; margin-top: 15px;">
                    <tr>
                        <td class="title-left-v">回避区域</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.hbqy" 
                                :defaultValue="currentRow.hbqy"
                                compType="Checkbox"
                                dictionaryType="观察员所属地市"
                            />
                            <!-- @selectHandleChange="selectHandleChangeOny('hbqy',currentRow.hbqy)" -->
                        </td>
                    </tr>
                    <tr>
                        <td class="title-left-v">专业特长</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.zytc" 
                                :defaultValue="currentRow.zytc"
                                compType="Checkbox"
                                dictionaryType="药品生产专业特长"
                                separateAreas='zytc001002'
                                
                            />
                            <!-- @selectHandleChange="selectHandleChangeOny('zytc',currentRow.zytc)" -->
                        </td>
                    </tr>
                    <tr>
                        <td class="title-left-v">组长人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fzzrs" :min="0" :precision="0" />
                        </td>
                        <td class="title-left-v">组员人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fzyrs" :min="0" :precision="0" />
                        </td>
                        <td class="title-left-v">预备审评员人数</td>
                        <td>
                            <a-input-number v-model:value="currentRow.fybrs" :min="0" :precision="0" />
                        </td>
                    </tr>
                    <!-- <tr>
                        <td class="title-left-v">是否发送确认短信</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.fsmszt" 
                                :defaultValue="currentRow.fsmszt"
                                compType="Radio"
                                :options="[{
                                    label:'是',
                                    value:'是',
                                }]"
                            />
                        </td>
                    </tr> -->
                    <!-- v-if="currentRow.fsmszt == '是'" -->
                    <tr >
                        <td class="title-left-v">短信内容<br/><span style="color: #ed5565;">（默认发送短信内容）</span></td>
                        <td colspan="5">
                            <a-textarea 
                                :key="fdqrdxnrKey"
                                v-model="currentRow.fdqrdxnr"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                                placeholder="请输入短信内容"
                            ></a-textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { sqsxYwxxinitDsrwAutoXpry, sqsxYwxxgetCxrySendDqrSmsNr, sqsxYwxxgetYxprySlhzt, } from "./service/index";
import compSelector from '@/components/compSelector/compSelector'
export default {
    components:{
        compSelector,
    },
    props:{

    },
    data(){
        return{
            visible:false,
            currentRow:{},
            fdqrdxnrKey:null,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row,rysl){
            this.currentRow = {
                ...row,
                fzzrs:row.fzzrs?row.fzzrs:0,
                fzyrs:row.fzyrs?row.fzyrs:0,
                fybrs:row.fybrs?row.fybrs:0,
                fsmszt:'是',
            }
            sqsxYwxxgetYxprySlhzt({sqsxid:this.currentRow.sqsxid}).then(res=>{
                if(res.code == 200){
                    //console.log('查询预设人员的数量',res)
                    this.rsData = res.result
                    if(res.result){
                        if(res.result.zzFlag){
                            this.currentRow.fzzrs = Number(rysl.fzzrs) - Number(res.result.xpFzzrs)>0?Number(rysl.fzzrs) - Number(res.result.xpFzzrs):0
                        }
                        if(res.result.zyFlag){
                            this.currentRow.fzyrs = Number(rysl.fzyrs) - Number(res.result.xpFzyrs)>0?Number(rysl.fzyrs) - Number(res.result.xpFzyrs):0
                        }
                        if(res.result.ybFlag){
                            this.currentRow.fybrs = Number(rysl.fybrs) - Number(res.result.xpFybrs)>0?Number(rysl.fybrs) - Number(res.result.xpFybrs):0
                        }
                        
                    }
                }else{

                }
                this.compSelectorkey = Date.now()
            })
            sqsxYwxxgetCxrySendDqrSmsNr({sqsxid:row.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.fdqrdxnrKey = Date.now()
                    this.currentRow.fdqrdxnr = res.result
                    //console.log('获取到什么短信内容',res.result)
                }else{}
            })
            this.compSelectorkey = Date.now()
        },
        handleOk(){
            if(this.currentRow.fzzrs || this.currentRow.fzyrs || this.currentRow.fybrs){
                if(this.currentRow.fsmszt == '是' && !this.currentRow.fdqrdxnr){
                    this.$message.warning('请输入短信内容')
                    return
                }
                this.confirmLoading = true
                let data = {
                    ...this.currentRow,
                    hbqy:this.currentRow.hbqy && this.currentRow.hbqy.length?this.currentRow.hbqy.join(','):'',
                    zytc:this.currentRow.zytc && this.currentRow.zytc.length?this.currentRow.zytc.join(','):'',
                }
                sqsxYwxxinitDsrwAutoXpry(data).then(res=>{
                    if(res.code == 200){
                        this.$message.success(res.message)
                        this.$emit('automaticSelectFromSuccess',this.currentRow)
                        this.visible = false
                    }else{
                        this.$message.warning(res.message)
                    }
                    this.confirmLoading = false
                })
            }else{
                this.$message.warning('请输入人数')
            }
            
        },

    }
}
</script>
<style lang="less">
.automaticSelectFrom-modal-box-v{
    td{
        padding: 5px;
        height: 30px;
    }
    .title-left-v{
        text-align: center;
        width: 260px;
        font-weight: 600;
        font-size: 16px;
        background-color:#e6f7ff;
        font-family: simHei;
        color: rgba(0, 0, 0, 0.85);
    }
}
</style>